-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Add DesugaringKind::FormatLiteral #142594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
Some changes occurred in compiler/rustc_ast_lowering/src/format.rs cc @m-ou-se |
We might want to block this on #140748, I'm relatively sure. Just FYI |
Why is that? |
Idk, if it's not conflicting according to git and if it's not stepping on each other's toes in other ways, I guess it's fine — I only skimmed boths diffs. Mara's PR will likely get approved soon anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, #141633 can be refactored after this.
compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
Show resolved
Hide resolved
0cd0b91
to
3858b2c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very meaningful and the impl looks fine. But adding a new desugaringKind
for diagnostics needs some opinions IMO
r? diagnostics
@@ -17,7 +19,9 @@ error[E0277]: `Bar` doesn't implement `Debug` | |||
--> $DIR/no-debug.rs:10:32 | |||
| | |||
LL | println!("{:?} {:?}", Foo, Bar); | |||
| ^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` | |||
| ---- ^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't, but it does make that PR easier to implement; they can simply replace all of the diagnostic item stuff with a matches!(span.desugaring_kind(), Some(rustc_span::DesugaringKind::FormatLiteral {..}))
@@ -4,9 +4,8 @@ error[E0277]: `a::Inner<T>` doesn't implement `Debug` | |||
LL | #[derive(Debug)] | |||
| ----- in this derive macro expansion | |||
LL | struct Outer<T>(Inner<T>); | |||
| ^^^^^^^^ `a::Inner<T>` cannot be formatted using `{:?}` | |||
| ^^^^^^^^ the trait `Debug` is not implemented for `a::Inner<T>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm neutral about this change. Maybe some beginners need to know the relationship between Debug and {:?}
. I am not sure about this.
Looks ok for me. @bors delegate+ |
✌️ @mejrs, you can now approve this pull request! If @chenyukang told you to " |
Add DesugaringKind::FormatLiteral Implements `DesugaringKind::FormatLiteral` to mark the FormatArgs desugaring of format literals. The main use for this is to stop yapping about about formatting parameters if we're not anywhere near a format literal. The other use case is to fix suggestions such as rust-lang#141350. It might also be useful for new or existing diagnostics that check whether they're in a format-like macro. cc `@xizheyin` `@fmease`
Rollup of 10 pull requests Successful merges: - #140254 (Pass -Cpanic=abort for the panic_abort crate) - #142594 (Add DesugaringKind::FormatLiteral) - #142600 (Port `#[rustc_pub_transparent]` to the new attribute system) - #142617 (improve search graph docs, reset `encountered_overflow` between reruns) - #142641 (Generate symbols.o for proc-macros too) - #142747 (rustdoc_json: conversion cleanups) - #142776 (All HIR attributes are outer) - #142800 (integer docs: remove extraneous text) - #142850 (remove asm_goto feature annotation, for it is now stabilized) - #142860 (Notify me on tidy changes) r? `@ghost` `@rustbot` modify labels: rollup
Implements
DesugaringKind::FormatLiteral
to mark the FormatArgs desugaring of format literals. The main use for this is to stop yapping about about formatting parameters if we're not anywhere near a format literal. The other use case is to fix suggestions such as #141350. It might also be useful for new or existing diagnostics that check whether they're in a format-like macro.cc @xizheyin @fmease